package com.gitee.kerraway.lang;

/**
 * @author 小柯
 * @date 2018/3/25
 */
public class Boxing {

  /**
   * new Integer(2) == 2 ?                            true
   * new Integer(2) == new Integer(2) ?               false
   * Integer.valueOf(2) == Integer.valueOf(2) ?       true
   * Integer.valueOf(128) == Integer.valueOf(128) ?   false (may be true, may be false)
   * Integer.valueOf(2).intValue() == 2 ?             true
   * (new Integer(2)).equals(new Integer(2)) ?        true
   */
  public static void main(String[] args) {
    System.out.printf("new Integer(2) == 2 ? %s\n", new Integer(2) == 2);
    System.out.printf("new Integer(2) == new Integer(2) ? %s\n", new Integer(2) == new Integer(2));
    System.out.printf("Integer.valueOf(2) == Integer.valueOf(2) ? %s\n", Integer.valueOf(2) == Integer.valueOf(2));
    System.out.printf("Integer.valueOf(128) == Integer.valueOf(128) ? %s\n", Integer.valueOf(128) == Integer.valueOf(128));
    System.out.printf("Integer.valueOf(2).intValue() == 2 ? %s\n", Integer.valueOf(2).intValue() == 2);
    System.out.printf("(new Integer(2)).equals(new Integer(2)) ? %s\n", (new Integer(2)).equals(new Integer(2)));
  }

}